package com.wan37.logic.task.service.impl;

import com.wan37.logic.task.dao.TaskDao;
import com.wan37.logic.task.domain.entity.TaskDO;
import com.wan37.logic.task.domain.vo.TaskVO;
import com.wan37.logic.task.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

/**
 * @author : luoyong
 * @date : 2020-08-08 15:06
 **/
@Service("taskService")
public class TaskServiceImpl implements TaskService {
    @Autowired
    private TaskDao taskDao;
    @Override
    public List<TaskVO> getTaskVOByUserId(String userId) {
        List<TaskDO> taskDOList = taskDao.findTaskDOByUserId(userId);
        if (taskDOList == null){
            return null;
        }
        List<TaskVO> taskVOList = new LinkedList<>();
        for (TaskDO taskDO : taskDOList){
            taskVOList.add(new TaskVO(taskDO));
        }
        return taskVOList;
    }

    @Override
    public boolean update(TaskVO taskVO) {
        return taskDao.update(new TaskDO(taskVO));
    }

    @Override
    public boolean save(TaskVO taskVO) {
        return taskDao.add(new TaskDO(taskVO));
    }

    @Override
    public boolean delete(TaskVO taskVO) {
        return false;
    }
}
